package drawer

import (
	"MetroBuilderGameJam/gameEngine/geom"
	"github.com/hajimehoshi/ebiten/v2"
	"image/color"
)

func DebugDrawerAnchors(screen *ebiten.Image) {
	screen.Fill(ColorSnow)
	pivots := []geom.Point{
		{100, 100},
		{100, 200},
		{100, 300},
		{100, 400},
		{200, 100},
		{200, 200},
		{200, 300},
		{200, 400},
	}
	drawFigures(screen, NewCentralDrawer(), pivots, ColorRed)

	d2 := NewDrawer(AnchorTopLeft)
	anchors := map[ebiten.Key]FigureAnchor{
		ebiten.Key1: AnchorTopRight,
		ebiten.Key2: AnchorTop,
		ebiten.Key3: AnchorLeft,
		ebiten.Key4: AnchorCenter,
		ebiten.Key5: AnchorRight,
		ebiten.Key6: AnchorBottomLeft,
		ebiten.Key7: AnchorBottom,
		ebiten.Key8: AnchorBottomRight,
	}
	for k, a := range anchors {
		if ebiten.IsKeyPressed(k) {
			d2 = NewDrawer(a)
		}
	}
	drawFigures(screen, d2, pivots, ColorBlack)
}

func drawFigures(screen *ebiten.Image, d *Drawer, pivots []geom.Point, clr color.RGBA) {
	d.PivotWidth = 2
	d.Circle(screen, pivots[0], 10, 1, clr)
	d.Square(screen, pivots[1], 10, 1, 0, clr)
	d.Cross(screen, pivots[2], 10, 1, 0, clr)
	d.SimpleTriangle(screen, pivots[3], 10, 1, 0, clr)
	d.Pentagon(screen, pivots[4], 10, 1, 0, clr)
	d.Star(screen, pivots[5], 10, 1, 0, clr)
}
